package javaFeatures.src.TestFeature.oopcourse;

public class ShapeDrawer {
    private int height;

    public ShapeDrawer(int height) {
        this.height = height;
    }

    public void drawTriangle() {
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < height - i - 1; j++) {
                System.out.print(" ");
            }
            for (int j = 0; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public void drawRectangle() {
        int width = height * 2; 
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                if (j < height || j >= width - height) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }

    public void drawSquare() {
    
        drawRectangle();
    }

    public void drawParallelogram() {
        int base = height;
        int side = height * 2;
        int offset = 0;

        offset = (side - base) / 2;

        for (int i = 0; i < height; i++) {
            for (int j = 0; j < offset + i; j++) {
                System.out.print(" ");
            }
            for (int j = 0; j < base; j++) {
                System.out.print("*");
            }
            for (int j = 0; j < (side - base - offset - i); j++) {
                System.out.print(" ");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        ShapeDrawer drawer = new ShapeDrawer(5);

        System.out.println("Triangle:");
        drawer.drawTriangle();
        System.out.println();

        System.out.println("Rectangle:");
        drawer.drawRectangle();
        System.out.println();

        System.out.println("Square:");
        drawer.drawSquare();
        System.out.println();

        System.out.println("Parallelogram:");
        drawer.drawParallelogram();
        System.out.println();
    }
}
